package duoxiancheng;

/**
 * 静态代理
 * 接口：
 * 1.真实角色
 * 2.代理角色
 */
public class jingtaidaili {
    public static void main(String[] args) {
        new Wedding(new You()).happyMary();

        //new Thread(线程对象).start();
    }
}

interface Marry{
    void happyMary();
}

//真实角色
class You implements Marry{
    @Override
    public void happyMary() {
        System.out.println("你终于脱单了");
    }
}

//代理角色
class Wedding implements Marry{
    //真实角色
    private Marry target;
    public Wedding(Marry target) {
        this.target = target;
    }

    @Override
    public void happyMary() {
        ready();
        this.target.happyMary();
        after();
    }

    private void ready(){
        System.out.println("准备工作");
    }

    private void after(){
        System.out.println("结束");
    }
}